home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-06 | 3.1 KB | 111 lines | [TEXT/MPCC] |
- // ————• WASTE Proxy Object—————————————————————————————————————————————————————————————
- // ———• by Chris K. Thomas, ckt@guest.apple.com
- // —• a proxy object is one that represents an object
- // —• which cannot be displayed, due to memory, system software, or whatever
-
- // ——• 4 Jun 95 ckt
-
- // ————• Includes——————————————————————————————————————————————————————————————————————
-
- #include "WEProxy.h" // ——• ourself
-
- // ————• Macros————————————————————————————————————————————————————————————————————————
-
- #define ThrowIfOSErr_(x) if(x != noErr) goto Exit
-
- // ————• Constants—————————————————————————————————————————————————————————————————————
-
- static const short kIconSize = 32;
- static const short kIconStartID = 1024;
- static const short kNumIcons = 5;
-
- // ————• Instance Variables————————————————————————————————————————————————————————————
-
- // ————• Static Prototypes—————————————————————————————————————————————————————————————
-
- static pascal OSErr HandleNewProxy(Point *defaultObjectSize, WEObjectReference objectRef);
- static pascal OSErr HandleDispose3D(WEObjectReference objectRef );
- static pascal OSErr HandleDraw3D(Rect *destRect, WEObjectReference objectRef );
-
- static UniversalProcPtr sNew3DRD;
- static UniversalProcPtr sDispose3DRD;
- static UniversalProcPtr sDraw3DRD;
-
- // ————• Installer——————————————————————————————————————————————————————————————————————
-
- OSErr WEObjProxyInstall(FlavorType inDataFlavor, inWEHandle inWaste)
- {
- OSErr theErr = noErr;
-
- // * mixed mode magic
-
- if(sNew3DRD == NULL)
- {
- sNew3DRD = NewWENewObjectProc(HandleNew3D);
- sDispose3DRD = NewWEDisposeObjectProc(HandleDispose3D);
- sDraw3DRD = NewWEDrawObjectProc(HandleDraw3D);
- }
-
- // * install
-
- theErr = WEInstallObjectHandler(inDataFlavor, weNewHandler, sNew3DRD, inWaste);
- ThrowIfOSErr_(theErr);
-
- theErr = WEInstallObjectHandler(inDataFlavor, weDisposeHandler, sDispose3DRD, inWaste);
- ThrowIfOSErr_(theErr);
-
- theErr = WEInstallObjectHandler(inDataFlavor, weDrawHandler, sDraw3DRD, inWaste);
- ThrowIfOSErr_(theErr);
-
- Exit:
- return theErr;
- }
-
- // ————• New handler—————————————————————————————————————————————————————————————————————
- pascal OSErr HandleNewProxy(Point *outDefaultSize, WEObjectReference inObjectRef)
- {
- OSErr theErr = noErr;
-
- outDefaultSize->h = kIconSize;
- outDefaultSize->v = kIconSize;
-
- WESetObjectRefCon(0, inObjectRef);
-
- Exit:
- return theErr;
- }
-
- // ————• Dispose handler—————————————————————————————————————————————————————————————————
- pascal OSErr HandleDispose3D(WEObjectReference inObjectRef)
- {
- OSErr theErr = noErr;
- ViewerObject curViewer;
- Handle data;
-
- // * dispose data
- data = WEGetObjectDataHandle(objectRef);
- DisposeHandle(data);
-
- return theErr;
- }
-
- // ————• Draw handler————————————————————————————————————————————————————————————————————
- pascal OSErr HandleDraw3D (Rect *inDestRect, WEObjectReference inObjectRef)
- {
- OSErr theErr = noErr;
- WEHandle ourWE;
- ViewerObject curViewer;
-
- // * retrieve port
- curViewer = (ViewerObject)WEGetObjectRefCon(inObjectRef);
-
- // * use new rectangle
- theErr = Q3ViewerSetBounds(curViewer, inDestRect);
- ThrowIfOSErr_(theErr);
- DrawS r
- // * draw
- theErr = Q3ViewerDraw(curViewer);
-
- Exit:
- return theErr;
- }